//package com.example.demo.config.springsecurity;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Service;
//
//@Service
//public class UserDetailsServiceImpl implements UserDetailsService {
//    @Autowired
//    UserInfoMapper userInfoMapper;
//
//    @Override
//    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
//        UserInfo userInfo = userInfoMapper.selectByName(s);
//        if (userInfo == null) {
//            throw new UsernameNotFoundException("用户" + s + "登录失败，用户名不存在");
//        }
//        // test-123456
//        // root-root
//        return User.withUsername(userInfo.getName())
//                .password(userInfo.getPassword())
//                .roles(userInfo.getRole())
//                .build();
//    }
//}
